﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace Sispe.UI.ReportesCeyca
{
    public partial class FrmHojaOperaciones : Form
    {
        public int IdLiquidacion;
        public FrmHojaOperaciones()
        {
            InitializeComponent();
        }

        private void FrmHojaOperaciones_Load(object sender, EventArgs e)
        {
            CargarHojaOperaciones();
        }

        private void CargarHojaOperaciones()
        {
            reportHojaOperaciones.ShowPageNavigationControls = false;
            reportHojaOperaciones.ShowCredentialPrompts = false;

            var user = ConfigurationManager.AppSettings.Get("userReport");
            var pws = ConfigurationManager.AppSettings.Get("pwsReport");
            reportHojaOperaciones.ServerReport.ReportServerCredentials.NetworkCredentials = new NetworkCredential(user, pws);

            var ipServer = ConfigurationManager.AppSettings.Get("ipServer");
            var path = ConfigurationManager.AppSettings.Get("pathO");
            reportHojaOperaciones.ProcessingMode = ProcessingMode.Remote;
            reportHojaOperaciones.ServerReport.ReportPath = path;
            reportHojaOperaciones.ServerReport.ReportServerUrl = new Uri(ipServer, System.UriKind.Absolute);

            ReportParameter[] parameters = new ReportParameter[1];
            parameters[0] = new ReportParameter("IdLiquidacion", IdLiquidacion.ToString());

            reportHojaOperaciones.ServerReport.SetParameters(parameters);
            this.reportHojaOperaciones.RefreshReport();
        }
    }
}
